<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Gmap_field extends Field_type
{
    function display_field()
    {
        $data = get_object_vars($this);
        //$this->template->add_javascript('/application/modules/content/content_fields/assets/js/maps_googleapis_nosensor.js');
        $this->template->add_javascript('http://maps.googleapis.com/maps/api/js?sensor=false');
        $this->template->add_javascript('/application/modules/content/content_fields/assets/js/jquery-gmaps-latlon-picker.js');
        return $this->load->view('gmap', $data, TRUE);
    }
    
    function validate()
    {
        return TRUE;
    }
    
    function save() 
    {
        if (is_null($this->content['lat1']))
        {
            $this->content['lat1'] = 60;
        }
        if (is_null($this->content['lat2']))
        {
            $this->content['lat2'] = 60;
        }
        if (is_null($this->content['long1']))
        {
            $this->content['long1'] = 30;
        }
        if (is_null($this->content['long2']))
        {
            $this->content['long2'] = 30;
        }
        return serialize($this->content);
    }
}
